const fs = require('fs')
const path = require('path')
const archiver = require('archiver')

const output = fs.createWriteStream(path.join(__dirname, '../dist.zip'))

const archive = archiver('zip', { zlib: { level: 9 } })

archive.pipe(output)

// archive.directory(path.join(__dirname, '../dist/assets'), false)
archive.directory(path.join(__dirname, '../dist/assets'), 'assets')

;['index.html', 'index.html.gz'].forEach((filename) => {
  archive.file(path.join(__dirname, '../dist/', filename), { name: filename })
})

archive.finalize()

archive.on('end', () => {
  console.log('压缩完成')
})
